<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>DST2-project: C:/opensource/dst2-projekt/src/kernel.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">DST2-project
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('kernel_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">C:/opensource/dst2-projekt/src/kernel.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="kernel_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00005"></a>00005 <span class="preprocessor">#ifndef KERNEL_H</span>
<a name="l00006"></a>00006 <span class="preprocessor"></span><span class="preprocessor">#define KERNEL_H</span>
<a name="l00007"></a>00007 <span class="preprocessor"></span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="comment">// Debug option</span>
<a name="l00010"></a>00010 <span class="comment">//#define       _DEBUG</span>
<a name="l00011"></a>00011 
<a name="l00012"></a>00012 <span class="comment">/*********************************************************/</span>
<a name="l00014"></a>00014 <span class="comment">/*********************************************************/</span>
<a name="l00015"></a>00015 
<a name="l00016"></a>00016 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00017"></a>00017 
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 <span class="preprocessor">#ifdef texas_dsp</span>
<a name="l00020"></a>00020 <span class="preprocessor"></span>
<a name="l00021"></a>00021 <span class="preprocessor">#define CONTEXT_SIZE    34-2 </span>
<a name="l00022"></a>00022 <span class="preprocessor"></span>
<a name="l00023"></a>00023 <span class="preprocessor">#else</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span>
<a name="l00025"></a><a class="code" href="kernel_8h.html#a1c5c9d4bb3418209e1fa76041b9d2189">00025</a> <span class="preprocessor">#define CONTEXT_SIZE    13 </span>
<a name="l00026"></a>00026 <span class="preprocessor"></span><span class="preprocessor">#define STACK_SIZE      100</span>
<a name="l00027"></a>00027 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00028"></a>00028 <span class="preprocessor"></span>
<a name="l00029"></a>00029 <span class="preprocessor">#define TRUE    1</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#define FALSE   !TRUE</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#define RUNNING 1</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define INIT    !RUNNING</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#define FAIL    0</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#define SUCCESS 1</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#define OK              1</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#define DEADLINE_REACHED        0</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span><span class="preprocessor">#define NOT_EMPTY               0</span>
<a name="l00041"></a>00041 <span class="preprocessor"></span>
<a name="l00042"></a>00042 <span class="preprocessor">#define SENDER          +1</span>
<a name="l00043"></a>00043 <span class="preprocessor"></span><span class="preprocessor">#define RECEIVER        -1</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span>
<a name="l00045"></a>00045 
<a name="l00046"></a>00046 <span class="keyword">typedef</span> <span class="keywordtype">int</span>             exception;
<a name="l00047"></a>00047 <span class="keyword">typedef</span> <span class="keywordtype">int</span>             bool;
<a name="l00048"></a>00048 <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>    uint;
<a name="l00049"></a>00049 <span class="keyword">typedef</span> <span class="keywordtype">int</span>             action;
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="keyword">struct  </span><a class="code" href="structl__obj.html">l_obj</a>;         <span class="comment">// Forward declaration</span>
<a name="l00052"></a>00052 
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 <span class="comment">// Task Control Block, TCB</span>
<a name="l00055"></a>00055 <span class="preprocessor">#ifdef texas_dsp</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058         void    (*PC)(); <span class="comment">// Program counter</span>
<a name="l00059"></a>00059         uint    *SP; <span class="comment">// Stack pointer</span>
<a name="l00060"></a>00060         uint    Context[<a class="code" href="kernel_8h.html#a1c5c9d4bb3418209e1fa76041b9d2189">CONTEXT_SIZE</a>]; <span class="comment">// TCB Context</span>
<a name="l00061"></a>00061         uint    StackSeg[STACK_SIZE]; <span class="comment">// TCB stack</span>
<a name="l00062"></a>00062         uint    DeadLine; <span class="comment">//The deadline of the TCB</span>
<a name="l00063"></a>00063 } <a class="code" href="kernel_8h.html#a0c24950e4a367e32a373235c34739781">TCB</a>;
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="preprocessor">#else</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span>
<a name="l00067"></a><a class="code" href="struct___t_c_b.html">00067</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct___t_c_b.html">_TCB</a>
<a name="l00068"></a>00068 {
<a name="l00070"></a><a class="code" href="struct___t_c_b.html#a447726ef246ec0df941f0c79e1793afc">00070</a>         uint    <a class="code" href="struct___t_c_b.html#a447726ef246ec0df941f0c79e1793afc">Context</a>[<a class="code" href="kernel_8h.html#a1c5c9d4bb3418209e1fa76041b9d2189">CONTEXT_SIZE</a>];  
<a name="l00072"></a><a class="code" href="struct___t_c_b.html#a70e3017d7f00e7f09da8a7e4d013d2cd">00072</a>         uint    *<a class="code" href="struct___t_c_b.html#a70e3017d7f00e7f09da8a7e4d013d2cd">SP</a>;
<a name="l00074"></a><a class="code" href="struct___t_c_b.html#aa3ee085e69f684e90b004c2692903398">00074</a>         void    (*<a class="code" href="struct___t_c_b.html#aa3ee085e69f684e90b004c2692903398">PC</a>)();
<a name="l00075"></a>00075         uint    SPSR;     
<a name="l00076"></a>00076         uint    StackSeg[STACK_SIZE];
<a name="l00078"></a><a class="code" href="struct___t_c_b.html#a6e0cb8e8c2ee8c6149fa980c2fbe05ea">00078</a>         uint    <a class="code" href="struct___t_c_b.html#a6e0cb8e8c2ee8c6149fa980c2fbe05ea">DeadLine</a>;
<a name="l00079"></a>00079 } <a class="code" href="kernel_8h.html#a0c24950e4a367e32a373235c34739781">TCB</a>;
<a name="l00080"></a>00080 <span class="preprocessor">#endif</span>
<a name="l00081"></a>00081 <span class="preprocessor"></span>
<a name="l00082"></a>00082 <span class="comment">// Message items</span>
<a name="l00083"></a><a class="code" href="structmsgobj.html">00083</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structmsgobj.html">msgobj</a> 
<a name="l00084"></a>00084 {
<a name="l00085"></a>00085         <span class="keywordtype">char</span>            *pData;
<a name="l00086"></a>00086         exception       Status;
<a name="l00087"></a>00087         <span class="keyword">struct </span><a class="code" href="structl__obj.html">l_obj</a>    *pBlock;
<a name="l00088"></a>00088         <span class="keyword">struct </span><a class="code" href="structmsgobj.html">msgobj</a>   *pPrevious;
<a name="l00089"></a>00089         <span class="keyword">struct </span><a class="code" href="structmsgobj.html">msgobj</a>   *pNext;
<a name="l00090"></a>00090 } <a class="code" href="structmsgobj.html">msg</a>;
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 <span class="comment">// Mailbox structure</span>
<a name="l00093"></a><a class="code" href="structmailbox.html">00093</a> <span class="keyword">typedef</span> <span class="keyword">struct </span>{
<a name="l00094"></a>00094         <a class="code" href="structmsgobj.html">msg</a>             *pHead;
<a name="l00095"></a>00095         <a class="code" href="structmsgobj.html">msg</a>             *pTail;
<a name="l00096"></a>00096         <span class="keywordtype">int</span>             nDataSize;
<a name="l00097"></a>00097         <span class="keywordtype">int</span>             nMaxMessages;
<a name="l00098"></a>00098         <span class="keywordtype">int</span>             nMessages;
<a name="l00099"></a>00099         <span class="keywordtype">int</span>             nBlockedMsg;
<a name="l00100"></a>00100 } <a class="code" href="structmailbox.html">mailbox</a>;
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 
<a name="l00103"></a>00103 <span class="comment">// Generic list item</span>
<a name="l00104"></a><a class="code" href="structl__obj.html">00104</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="structl__obj.html">l_obj</a> {
<a name="l00105"></a>00105          <a class="code" href="struct___t_c_b.html">TCB</a>            *pTask;
<a name="l00106"></a>00106          uint           nTCnt;
<a name="l00107"></a>00107          <a class="code" href="structmsgobj.html">msg</a>            *pMessage;
<a name="l00108"></a>00108          <span class="keyword">struct </span><a class="code" href="structl__obj.html">l_obj</a>   *pPrevious;
<a name="l00109"></a>00109          <span class="keyword">struct </span><a class="code" href="structl__obj.html">l_obj</a>   *pNext;
<a name="l00110"></a>00110 } <a class="code" href="structl__obj.html">listobj</a>;
<a name="l00111"></a>00111 
<a name="l00112"></a>00112 
<a name="l00113"></a>00113 <span class="comment">// Generic list</span>
<a name="l00114"></a><a class="code" href="struct__list.html">00114</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__list.html">_list</a>
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116          <a class="code" href="structl__obj.html">listobj</a>        *pHead;
<a name="l00117"></a>00117          <a class="code" href="structl__obj.html">listobj</a>        *pTail;
<a name="l00118"></a>00118 } <a class="code" href="struct__list.html">list</a>;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 <span class="comment">// Function prototypes</span>
<a name="l00122"></a>00122 
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 <span class="comment">// Task administration</span>
<a name="l00127"></a>00127 <span class="comment"></span><span class="keywordtype">int</span>             init_kernel(<span class="keywordtype">void</span>);
<a name="l00128"></a>00128 exception       create_task( <span class="keywordtype">void</span> (* body)(), uint deadline );
<a name="l00129"></a>00129 <span class="keywordtype">void</span>            terminate( <span class="keywordtype">void</span> );
<a name="l00130"></a>00130 <span class="keywordtype">void</span>            run( <span class="keywordtype">void</span> );
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 <span class="comment">// Communication</span>
<a name="l00134"></a>00134 <span class="comment"></span><a class="code" href="structmailbox.html">mailbox</a>*        create_mailbox(<span class="keywordtype">int</span> nof_msg, <span class="keywordtype">int</span> size_of_msg);
<a name="l00135"></a>00135 <span class="keywordtype">int</span>             no_messages( <a class="code" href="structmailbox.html">mailbox</a>* mBox );
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 exception       send_wait( <a class="code" href="structmailbox.html">mailbox</a>* mBox, <span class="keywordtype">void</span>* pData );
<a name="l00138"></a>00138 exception       receive_wait( <a class="code" href="structmailbox.html">mailbox</a>* mBox, <span class="keywordtype">void</span>* pData );
<a name="l00139"></a>00139 
<a name="l00140"></a>00140 exception       send_no_wait( <a class="code" href="structmailbox.html">mailbox</a>* mBox, <span class="keywordtype">void</span>* pData );
<a name="l00141"></a>00141 <span class="keywordtype">int</span>             receive_no_wait( <a class="code" href="structmailbox.html">mailbox</a>* mBox, <span class="keywordtype">void</span>* pData );
<a name="l00142"></a>00142 
<a name="l00143"></a>00143 
<a name="l00144"></a>00144 <span class="comment">// Timing</span>
<a name="l00145"></a>00145 exception       wait( uint nTicks );
<a name="l00146"></a>00146 <span class="keywordtype">void</span>            set_ticks( uint no_of_ticks );
<a name="l00147"></a>00147 uint            ticks( <span class="keywordtype">void</span> );
<a name="l00148"></a>00148 uint            deadline( <span class="keywordtype">void</span> );
<a name="l00149"></a>00149 <span class="keywordtype">void</span>            set_deadline( uint nNew );
<a name="l00150"></a>00150 
<a name="l00151"></a>00151 <span class="comment">//Interrupt</span>
<a name="l00152"></a>00152 <span class="keyword">extern</span> <span class="keywordtype">void</span>     isr_off(<span class="keywordtype">void</span>);
<a name="l00153"></a>00153 <span class="keyword">extern</span> <span class="keywordtype">void</span>     isr_on(<span class="keywordtype">void</span>);
<a name="l00154"></a>00154 <span class="keyword">extern</span> <span class="keywordtype">void</span>     SaveContext( <span class="keywordtype">void</span> );    <span class="comment">// Stores DSP registers in TCB pointed to by Running</span>
<a name="l00155"></a>00155 <span class="keyword">extern</span> <span class="keywordtype">void</span>     LoadContext( <span class="keywordtype">void</span> );    <span class="comment">// Restores DSP registers from TCB pointed to by Running</span>
<a name="l00156"></a>00156 
<a name="l00157"></a>00157 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="kernel_8h.html">kernel.h</a>      </li>

    <li class="footer">Generated on Tue Jan 24 2012 15:04:14 for DST2-project by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.6.1 </li>
   </ul>
 </div>


</body>
</html>
